How can I get an Active Directory data code from System.DirectoryServices[.Protocols]?

Posted by Alex Waddell on Stack Overflow See other posts from Stack Overflow or by Alex Waddell
Published on 2010-04-21T16:00:36Z Indexed on 2010/04/21 16:03 UTC
Read the original article Hit count: 214

Filed under:
|

When using .Protocols, I can run the following pseudocode to authenticate to an AD:

try
{
   LdapConnection c = new LdapConnection("User", "Password");
   c.Bind();
}
catch (LdapException le)
{
   Debug.WriteLine(le.ResultCode);
}

This code will allow me to get the "Invalid Credentials" error string, and the AD code "49", but I need to get the additional data errors similar to an LDAP Java client :

[LDAP: error code 49 - 80090308: LdapErr: DSID-0C09030F, comment: AcceptSecurityContext error, data **525**, vece ]

525 – user not found
52e – invalid credentials (bad password)
530 – logon time restriction
532 – password expired
533 – account disabled
701 – account expired
773 – user must reset password

© Stack Overflow or respective owner

Related posts about c#

Related posts about ldap